import request from '@/utils/request'

//从配置中获取业务的地址
import {baseUrlConfig} from '@/config/config'
const businessBaseUrl = baseUrlConfig.businessBaseUrl
const processBaseUrl = baseUrlConfig.processBaseUrl

//获取分页列表
export const getProjectPageList: (data: any) => Promise<[]> = (data) => {
    return request({
        url: processBaseUrl + '/cm/project/find/page',
        method: 'post',
        data
    })
}

export const getProjectDetail: (id: any) => Promise<[]> = (id) => {
    return request({
        url: processBaseUrl + `/cm/project/info/${id}`,
        method: 'get',
    })
}

export const createProject: (data: any) => Promise<[]> = (data) => {
    return request({
        url: processBaseUrl + '/cm/project/append',
        method: 'post',
        data
    })
}

export const updateProject: (data: any) => Promise<[]> = (data) => {
    return request({
        url: processBaseUrl + '/cm/project/update',
        method: 'post',
        data
    })
}

export const changeProject: (data: any) => Promise<[]> = (data) => {
    return request({
        url: processBaseUrl + '/cm/project/change',
        method: 'post',
        data
    })
}

// 查询条件数量统计
export const getProjectConditionsStatNum: () => Promise<[]> = () => {
    return request({
        url: processBaseUrl + '/cm/project/conditionsInfo',
        method: 'get',
    })
}

// 项目审批
export const approveProject: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/approve',
    method: 'post',
    data
  })
}

// 常用节点
export const getCommonProcessNodes: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/processNode/common',
    method: 'get',
    data
  })
}

export const exportProjectList: (data: any) => Promise<[]> = (data) => {
  return request({
    responseType: 'blob',
    url: processBaseUrl + '/cm/project/exportXls',
    method: 'post',
    data
  })
}

// 历史审批记录
export const getProcessInfoHistory: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/processInfo/history',
    method: 'post',
    data
  })
}

// 开工前的流程审批
export const approveBeforeProjectStart: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/beforeProjectStartApprove',
    method: 'post',
    data
  })
}

// 申请延期
export const applyDelay: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/extension',
    method: 'post',
    data
  })
}

// 审批申请延期
export const reviewApplyDelay: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/extensionApprove',
    method: 'post',
    data
  })
}

// 申请上传验收单
export const applyUploadDepositrefund: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/uploadDepositrefund',
    method: 'post',
    data
  })
}

// 申请验收
export const applyHandover: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/depositrefund',
    method: 'post',
    data
  })
}

// 审批申请验收
export const reviewHandover: (data: any) => Promise<[]> = (data) => {
  return request({
    url: processBaseUrl + '/cm/project/depositrefundApprove',
    method: 'post',
    data
  })
}




